/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.hazard.alarm.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hopes.bizz.basic.common.constant.enums.ParkBasicModDictEnum;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.hazard.common.constant.enums.HazardSysDictEnum;
import com.hopes.bizz.hazard.common.logic.AlarmLogic;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 危险源超标报警
 *
 * @author daijie
 * @date 2023-11-16 19:26:17
 */
@Data
@TableName("haz_alarm_overproof")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "危险源超标报警")
public class HazAlarmOverproofEntity extends BaseLogicEntity {

    private static final long serialVersionUID = 1L;


    /**
     * 标识
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "标识")
    private Long id;

    /**
     * 超标数据类型 rt.实时数据超标 hour.小时数据超标
     */
    @Schema(description = "超标数据类型 rt.实时数据超标 hour.小时数据超标")
    private String alarmDataType;

    /**
     * 危险源
     */
    @Schema(description = "危险源")
    private Long hazardSourceId;

    /**
     * 报警因子
     */
    @Schema(description = "报警因子")
    private Long monitorFactorId;

    /**
     * 超标等级
     */
    @Schema(description = "超标等级")
    private String alarmLevel;

    /**
     * 高低报
     */
    @Schema(description = "高低报")
    private String highOrLow;

    /**
     * 报警报警值
     */
    @Schema(description = "报警报警值")
    private BigDecimal alarmValue;

    /**
     * 监测值
     */
    @Schema(description = "监测值")
    private BigDecimal monitorData;

    /**
     * 超标倍数
     */
    @Schema(description = "超标倍数")
    private BigDecimal alarmMultiple;

    /**
     * 报警时间
     */
    @Schema(description = "报警时间")
    private Date alarmTime;

    /**
     * 解除时间
     */
    @Schema(description = "解除时间")
    private Date removeTime;

    /**
     * 持续时间
     */
    @Schema(description = "持续时间")
    private Long durationTime;

    /**
     * 报警状态
     */
    @Schema(description = "报警状态")
    private String alarmStatus;

    /**
     * 处理状态
     */
    @Schema(description = "处理状态")
    private String handleStatus;

    /**
     * 报警内容
     */
    @Schema(description = "报警内容")
    private String alarmContent;

    /**
     * 机构ID
     */
    @Schema(description = "机构ID")
    private Long orgId;


    public String getRemoveTimeStr() {
        return DateUtils.limitDay(this.getRemoveTime());
    }

    public String getAlarmTimeStr() {
        return DateUtils.limitMinute(this.getAlarmTime());
    }

    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, this.getOrgId());
    }

    public String getHazardSourceIdStr() {
        return DictResolver.getItemLabelByValue(ParkBasicModDictEnum.hazard_source, this.getHazardSourceId());
    }

    public String getMonitorFactorIdStr() {
        return DictResolver.getItemLabelByValue(ParkBasicModDictEnum.monitor_factor, this.monitorFactorId);
    }

    public String getAlarmStatusStr() {
        return DictResolver.getItemLabelByValue(HazardSysDictEnum.hazard_alarm_status, this.alarmStatus);
    }

    public String getHandleStatusStr() {
        return DictResolver.getItemLabelByValue(HazardSysDictEnum.hazard_alarm_handle_status, this.handleStatus);
    }

    public String getDurationTimeStr() {
        return AlarmLogic.buildDurationTimeDesc(this.getAlarmTime(), this.getRemoveTime(), this.getDurationTime() * 60, this.getAlarmStatus());
    }


}
